// pages/photo/allResult/allResult.js
const app = getApp()
var base_url = app.globalData.url
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {
      avatarUrl: "",//用户头像
      nickName: "",//用户昵称
    },
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    /**
     * 获取用户信息
     */
    wx.getUserInfo({
      success: function (res) {
        console.log(res);
        var avatarUrl = 'userInfo.avatarUrl';
        var nickName = 'userInfo.nickName';
        that.setData({
          [avatarUrl]: res.userInfo.avatarUrl,
          [nickName]: res.userInfo.nickName,
        })
      }
    })


    wx.getStorage({
      key: 'uhid',
      success: function (res) {
        wx.request({
          url: base_url+'/thisExerciseDetail/',
          method: 'POST',
          data: {
            uhid: res['data'],
          },
          header: {
            "Content-Type": "application/x-www-form-urlencoded"
          },
          success: function (res) {
            console.log(res.data['dic'])
            that.setData({
              dic: res.data['dic'],
              // sysFile: res.data['sysFile']
            })
            if (res.data['dic']['comment'] == '-'){
              that.setData({
                b1: 'gray',
                b2: 'gray',
                b3: 'gray'
              })
            } else if (res.data['dic']['comment'] == '优'){
              that.setData({
                b1:'linear-gradient(to right, #01B6B1, #03CD9E)',
                b2:'gray',
                b3:'gray'
              })
            } else if (res.data['dic']['comment'] == '良') {
              that.setData({
                b2: 'linear-gradient(to right, #01B6B1, #03CD9E)',
                b1: 'gray',
                b3: 'gray'
              })
            } else if (res.data['dic']['comment'] == '中') {
              that.setData({
                b3: 'linear-gradient(to right, #01B6B1, #03CD9E)',
                b2: 'gray',
                b1: 'gray'
              })
            }
          }
        })
      },
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  tosinResult: function () {
    wx.navigateTo({
      url: '../../photo/sinResult/sinResult'
    })
  },
  seePic: function () {
    wx.previewImage({
      current: this.data.dic['picpath'], // 当前显示图片的http链接
      urls: [this.data.dic['picpath']]
    })
    // wx.getStorage({
    //   key: 'path',
    //   success: function (res) {
        
    //   },
    // })

  }
})